<?php

/**
 * uniBoard Admin Paginator Template
 *
 * Light and fast forum solution for web 2.0-like communities.
 *
 * @package		uniBoard
 * @author		Rafał Pitoń
 * @license		http://www.gnu.org/licenses/gpl-3.0.html
 * @since		Version 0.1
 * 
 * ------------------------------------------------------------------------
 * 
 * $Date: 2010-08-29 18:56:02 +0000 (Sun, 29 Aug 2010) $
 * $Revision: 51 $
 * $Author: rafio.xudb@gmail.com $
 */

// ------------------------------------------------------------------------

class tpl_paginator extends class_templates_abstract{
	
	/**
	 * Main class pointer
	 *
	 * @var object
	 */
	
	private $appCore	= NULL;

	/**
	 * Zebras list
	 *
	 * @var array
	 */
	
	public $zebras 		= array();
	
	// ------------------------------------------------------------------------

	/**
	 * Creates ACP display class
	 *
	 * @param object $appCore
	 */
	
	function __construct( $appCore){
		
		// Store appCore pointer
		$this -> appCore = $appCore;
		
	}
	
	// ------------------------------------------------------------------------

	/**
	 * Paginator JS
	 *
	 * @param array $tpl_vars
	 * @return string
	 */
	
	function tpl_pager_js( $tpl_vars = array()){
		
		return '// PAGINATOR JS START

	var page_base_url = \'' . addslashes( $tpl_vars['page_base_url']) . '\';
		
	$(document).ready( function(){
		$(\'.paginator_page_jump\').click( function(){
			var user_page = prompt( \'' . addslashes( sprintf( $this -> appCore -> lang['paginator_page_jump_message'], $tpl_vars['pages_total'])) . '\');
			
			if ( user_page !== null && !isNaN(user_page) && user_page > 0 && user_page <= ' . $tpl_vars['pages_total'] . ')
			{
				document.location.href = page_base_url.replace( \'%s\', ( ( user_page - 1) * ' . $tpl_vars['page_size'] . '));
			}
		});
	});
	
// PAGINATOR JS END';
		
	}
	
	// ------------------------------------------------------------------------

	/**
	 * Full Paginator Body
	 *
	 * @param array $tpl_vars
	 * @return string
	 */
	
	function tpl_paginator_body( $tpl_vars = array()){
		
		return '<div class="paginator_body">
	<div class="paginator_border">
		' . ( $tpl_vars['pages_total'] > 0 ? '<a href="#" class="paginator_item paginator_page_jump">' . $this -> appCore -> output -> drawImage( 'page_jump', $this -> appCore -> lang['paginator_page_jump']) . '</a>' : '') . $tpl_vars['pages_list'] . '
	</div>
</div>';
		
	}
	
	// ------------------------------------------------------------------------

	/**
	 * Draws Unselected Page
	 *
	 * @param array $tpl_vars
	 * @return string
	 */
	
	function tpl_page( $tpl_vars = array()){
		
		return '<a href="' . $tpl_vars['page_link'] . '" class="paginator_item">' . $tpl_vars['page_number'] . '</a>';
		
	}
	
	// ------------------------------------------------------------------------

	/**
	 * Draws Selected Page
	 *
	 * @param array $tpl_vars
	 * @return string
	 */
	
	function tpl_page_active( $tpl_vars = array()){
		
		return '<a href="' . $tpl_vars['page_link'] . '" class="paginator_item_active">' . $tpl_vars['page_number'] . '</a>';
		
	}
	
}